<?php
$table = $this->uri->segment(3,0);
$url_ajax = base_url().'admin/ajax_field/order';
$url_ajax_sotrang = base_url().'admin/ajax_field/num';
$url_ajax_pub = base_url().'admin/ajax_field/pub/'.$table;
$url_ajax_where = base_url().'admin/ajax_field/where/'.$table;
?>
<?php include('ajax.php'); ?>
<div id="main-content">
    <div class="container">
    	<div class="row">
    		<div id="content" class="col-lg-12">
    			<!-- PAGE HEADER-->
                    <div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<div class="clearfix">
										<h3 class="content-title pull-left">Quản lí email gửi - nhận của thành viên</h3>
									</div>
								</div>
							</div>
					</div>
                    <!-- DATA TABLES -->
						<div class="row">
							<div class="col-md-12">
								<!-- BOX -->
								<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>Danh sách</h4>
										<div class="tools hidden-xs">
											<a href="javascript:;" data-toggle="tooltip" title="Ẩn đi" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
										</div>
									</div>
									<div class="box-body">
                                    <?php if(!empty($data)): ?>
										<table id="datatable1" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
											<thead>
												<tr>
                                                    <th>STT</th>
													<th>Email người gửi</th>
													<th class="center">Tiêu đề</th>
													<th class="center hidden-xs">Ngày gửi</th>
                                                    <th class="center hidden-xs">Email người nhận</th>
													<th class="center">Xác nhận</th>
													<th class="center">Sửa</th>
													<th class="center">Xóa</th>
												</tr>
											</thead>
											<tbody>
                                            <?php 
												$i=0; foreach ($data as $data) : $i++; if($data->status==0){$bien=' chuadoc ';}else{$bien='';} 
												$desc = str_replace("<p>","",$data->description);
												$desc = str_replace("</p>","",$desc);
											?>
												<tr class="gradeX">
													<td><?php echo $i;?></td>
													<td class="<?php echo $bien;?>" ><?php echo $data->email_from;  ?></td>
													<td class="center <?php echo $bien;?>"><?php echo $data->subjects;  ?></td>
													<td class="center <?php echo $bien;?> hidden-xs"><?php echo $data->date;  ?></td>
                                                    <td class="<?php echo $bien;?>" ><?php echo $data->email_to;  ?></td>
													<td class="center">
														<form method="POST" id="xacnhan_<?php echo $i;?>" action="<?php echo base_url().'admin/xuly/email/list/'.$data->id;?>">
														<input type="hidden" name="publish" value="1">
														<a href="#" onclick="document.getElementById('xacnhan_<?php echo $i;?>').submit();"><i class="fa fa-check-square-o fa-2x"></i></a>
														</form>
													</td>
													<td class="center"><a href="<?php echo base_url().'admin/xuly/email/edit/'.$data->id?>"><i class="fa fa-edit fa-2x"></i></a></td>
                                                    <td class="center"><a onclick="return confirm('Bạn có muốn xóa không?');" href="<?php echo base_url().'admin/xuly/email/xoa/'.$data->id.'/'.$this->uri->segment(5)?>"><i class="fa fa-trash-o fa-2x red"></i></a></td>
												</tr>
                                                <?php endforeach; ?>
											</tbody>
										</table>
                                        <div class="row">
                                               <div class="col-sm-12">
                                                  <div class="pull-right">
                                                           <?php echo $this->pagination->create_links();?>
                                                  </div>
                                                  <div class="clearfix"></div>
                                               </div>
                                            </div>
                                        <?php endif; ?>
                                        <a href="<?php echo base_url().'admin/xuly/email/edit'; ?>" title="Thêm mới" class="btn btn-success"><i class="fa fa-angle-double-right"></i>&nbsp;&nbsp;&nbsp;Thêm mới</a>
									</div>
								</div>
								<!-- /BOX -->
							</div>
						</div>
						<!-- /DATA TABLES -->
    			</div>
    			<!-- /PAGE HEADER -->
    		</div>
    	</div>
    </div>
</div>